package com.thinvent.nj.ais.conf;

import org.springframework.cache.Cache;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *
 * 自定义Config
 *
 * @author liupeijun
 * @date 2018/05/28
 *
 */
@Configuration
public class MyCommonConfig {

    /**
     * 字典cache
     * @param ehCacheCacheManager
     * @return
     */
    @Bean(name = "dictCache")
    public Cache dictCache(EhCacheCacheManager ehCacheCacheManager) {
        ehCacheCacheManager.getCacheManager().addCache("dict");

        return ehCacheCacheManager.getCache("dict");
    }


    /**
     * 系统cache
     * @param ehCacheCacheManager
     * @return
     */
    @Bean(name = "sysCache")
    public Cache sysCache(EhCacheCacheManager ehCacheCacheManager) {
        ehCacheCacheManager.getCacheManager().addCache("sys");

        return ehCacheCacheManager.getCache("sys");
    }
}
